var autoReload = {
	auto : false,
	_timeout : null,
	cds : 0, //倒计时
	cdsSize : 60,
	init : function(){
		$('#reloadSwitch').unbind("click").bind("click", function(){
			autoReload.clickCheck();
			if (autoReload.auto) {
				$(this).addClass("btn_checked");
			} else {
				$(this).removeClass("btn_checked");
			}
		});
		this.setAuto(true);
		$('#reloadSwitch').addClass("btn_checked");
		this.showSize();
	},
	reset : function(){
		this.resetAuto();
		this.cdsSize = 60;
		this.showSize();
	},
	resetAuto : function(){
		this.setAuto(true);
	},
	setCdsSize : function(value){
		this.cdsSize = value;
		this.cds = value;
		this.showSize();
		saveCookie();
	},
	showSize : function(){
		var html = '';
		if(this.cdsSize == 30){
			html += '<span class="selected">30秒</span> ';
		}else{
			html += '<a href="javascript:void(0)" onclick="autoReload.setCdsSize(30);return false;">30秒</a> ';
		};
		if(this.cdsSize == 60){
			html += '<span class="selected">60秒</span> ';
		}else{
			html += '<a href="javascript:void(0)" onclick="autoReload.setCdsSize(60);return false;">60秒</a> ';
		};
		if(this.cdsSize == 90){
			html += '<span class="selected">90秒</span> ';
		}else{
			html += '<a href="javascript:void(0)" onclick="autoReload.setCdsSize(90);return false;">90秒</a> ';
		};
		$('#reloadTimeout').html(html);
	},
	clickCheck : function(){
		if(this.auto === true){
			this.setAuto(false);
		}else{
			this.setAuto(true);
		};
	},
	setAuto : function(value){
		this.auto = value;
		if(value === true){
			this.cds = this.cdsSize;
			this._countDown();
		}else{
			clearTimeout(this._timeout);
			$('#remain').text('00');
		};
	},
	mReload : function(){ //手动刷新
		clearTimeout(this._timeout);
		instant.init();
		$('#remain').text('00');
	},
	_countDown : function(){
		var tempThis = this;
		this.cds --;
		$('#remain').text(this.cds>9?this.cds:'0' + this.cds);
		
		if(this.cds <= 0){
			this.mReload();
			return;
		};
		if(this.auto === true){
			clearTimeout(this._timeout);
			this._timeout = setTimeout(function(){tempThis._countDown()},1000);
		};
	}
};